package com.tqjc.system.system.wrapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tqjc.system.common.Wrapper.BaseWrapper;
import com.tqjc.system.common.enums.TankCarNoEnum;
import com.tqjc.system.common.enums.TaskStatusEnum;
import com.tqjc.system.system.entity.SysAddPrimaryTaskEntity;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @Author: 86195
 * @Date: 2024/1/3 9:46
 **/
public class AddPrimaryTaskWraper extends BaseWrapper<SysAddPrimaryTaskEntity> {

    public AddPrimaryTaskWraper(IPage<SysAddPrimaryTaskEntity> pageResult) {
        super(pageResult);

        List<SysAddPrimaryTaskEntity> records = pageResult.getRecords();
        if(CollectionUtils.isNotEmpty(records)){
            List<SysAddPrimaryTaskEntity> res = new ArrayList<>(records.size());
            records.forEach( e ->{
                e.setStatus(TaskStatusEnum.getDescByStatus(e.getStatus()));
                if(e.getTankCarNo() == null){
                    e.setTankCarNo("无槽车信息");
                } else {
                    e.setTankCarNo(TankCarNoEnum.getEnum(e.getTankCarNo()).getTankName());
                }

                res.add(e);
            });
            pageResult.setRecords(res);
        }

    }


}
